{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f47a7624",
   "metadata": {},
   "source": [
    "------\n",
    "* 2023-11-20\n",
    "* 课程：python语言\n",
    "* week12\n",
    "------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a64623b6",
   "metadata": {},
   "source": [
    "# 1. 字典的创建\n",
    "\n",
    "> 1. 按照数据结构的形态创建：[,],(,),{,}\n",
    "> 2. 按照数据结构的方法创建：list（）,tuple(),set(),dict()\n",
    "> 3. 根据自身的性质创建：\n",
    ">>  A.  [],append\n",
    ">>  B.  VALUE1,VALUE2,VALUE3\n",
    ">>  C."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0edd76fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'jessa', 'country': 'USA', 'telephone': 1178}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "# 方法一：\n",
    "person = {\n",
    "    \"name\": \"jessa\",\n",
    "    \"country\": \"USA\",\n",
    "    \"telephone\": 1178\n",
    "}\n",
    "print(person)\n",
    "print(type(person))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "de1bdafa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'jessa', 'country': 'USA', 'telephone': 1178}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "# 方法一：\n",
    "person = dict(\n",
    "    name = \"jessa\",\n",
    "    country = \"USA\",\n",
    "    telephone = 1178\n",
    ")\n",
    "print(person)\n",
    "print(type(person))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "075507da",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'jessa', 'country': 'USA', 'telephone': '1178'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "# 方法三：字典新增\n",
    "person = {}\n",
    "person['name'] = \"jessa\"\n",
    "person['country'] = \"USA\"\n",
    "person['telephone'] = \"1178\"\n",
    "print(person)\n",
    "print(type(person))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "acbced00",
   "metadata": {},
   "source": [
    "# 2. 字典的一般方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1e9d67c3",
   "metadata": {},
   "source": [
    "## 1. 查询\n",
    "\n",
    "> in 方法:查询dict中是否存在其关键词key\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "20964e41",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'name' in person"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3b7ea13e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'jessa' in person"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5eab2cd7",
   "metadata": {},
   "outputs": [],
   "source": [
    "person.get(\"jessa\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "29c019b8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "jessa\n"
     ]
    }
   ],
   "source": [
    "person = {\n",
    "    \"name\": \"jessa\",\n",
    "    \"country\": \"USA\",\n",
    "    \"telephone\": 1178\n",
    "}\n",
    "keys = 'name'\n",
    "if keys in person:\n",
    "     print(person.get(keys))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9444e664",
   "metadata": {},
   "source": [
    "# 2. 字典的items方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "fb5ab0a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_items([('name', 'jessa'), ('country', 'USA'), ('telephone', '1178')])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person.items()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1da7d04d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name\n",
      "country\n",
      "telephone\n"
     ]
    }
   ],
   "source": [
    "# 循环一个元素得到的结果是key\n",
    "for i in person:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "dce9cfbb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name jessa\n",
      "country USA\n",
      "telephone 1178\n"
     ]
    }
   ],
   "source": [
    "# k=key,v=value\n",
    "for k,v in person.items():\n",
    "    print(k,v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "eb45d520",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'小明': 80, '小红': 85, 'jessa': 95}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 案例:需求，找出所有的大于90分的同学\n",
    "python_成绩 = {\n",
    "    \"小明\": 80,\n",
    "    \"小红\": 85,\n",
    "    \"jessa\": 95\n",
    "}\n",
    "python_成绩"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "55f673db",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "jessa 95\n"
     ]
    }
   ],
   "source": [
    "for k,v in python_成绩.items():\n",
    "    if v > 90:\n",
    "        print(k,v)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e4ddc88",
   "metadata": {},
   "source": [
    "# 3.字典的keys，values方法\n",
    "\n",
    "> 1. keys：可以查看所有关键词，大致了解下有哪些属性\n",
    "> 2. values：可以查看所有的结果，大致了解下结果的特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ceffe94b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['name', 'country', 'telephone'])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "2b43c489",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f78588fd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'args': {},\n",
       " 'headers': {'Accept': '*/*',\n",
       "  'Accept-Encoding': 'gzip, deflate, br',\n",
       "  'Host': 'httpbin.org',\n",
       "  'User-Agent': 'python-requests/2.31.0',\n",
       "  'X-Amzn-Trace-Id': 'Root=1-655b499c-71a61ebe7d5ce643001a4d0c'},\n",
       " 'origin': '120.85.143.176',\n",
       " 'url': 'https://httpbin.org/get'}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r = requests.get(\"https://httpbin.org/get\")\n",
    "results = r.json()\n",
    "results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "edcdb1bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['args', 'headers', 'origin', 'url'])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "470ade76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['Accept', 'Accept-Encoding', 'Host', 'User-Agent', 'X-Amzn-Trace-Id'])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results['headers'].keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "965e00b5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_values(['jessa', 'USA', '1178'])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person.values()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "61bd8bec",
   "metadata": {},
   "source": [
    "# 4.字典的删除: pop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "9520bcd6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'jessa', 'country': 'USA', 'telephone': '1178'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "person = {}\n",
    "person['name'] = \"jessa\"\n",
    "person['country'] = \"USA\"\n",
    "person['telephone'] = \"1178\"\n",
    "print(person)\n",
    "print(type(person))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "ed385efb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'jessa', 'country': 'USA', 'telephone': '1178'}"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 一般情况下，所有数据做删除操作时，都会有 备份 的操作\n",
    "person_备份 = person.copy()\n",
    "person_备份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "32061669",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'jessa', 'telephone': '1178'}"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "if \"country\" in person:\n",
    "    person.pop(\"country\")\n",
    "person"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "17c02d40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'jessa', 'country': 'USA', 'telephone': '1178'}"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person_备份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "54d89a4a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'jessa', 'telephone': '1178'}"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "3c449fd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('telephone', '1178')"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person.popitem()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "c3e32ec0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': 'jessa'}"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a2a011c",
   "metadata": {},
   "source": [
    "# 4. 关于字典的特殊（高级）用法\n",
    "\n",
    "> 1. fromkeys()\n",
    "> 2. setdefault()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "58f7f396",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'jessa', 'country': 'USA', 'telephone': '1178'}\n",
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "person = {}\n",
    "person['name'] = \"jessa\"\n",
    "person['country'] = \"USA\"\n",
    "person['telephone'] = \"1178\"\n",
    "print(person)\n",
    "print(type(person))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "ac766173",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function fromkeys:\n",
      "\n",
      "fromkeys(iterable, value=None, /) method of builtins.type instance\n",
      "    Create a new dictionary with keys from iterable and values set to value.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(person.fromkeys)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "9dafda16",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 我们可以创建一个字典，字典的value，可以自定义（初始化）\n",
    "\n",
    "name_list = [\"刘同\",\"李玲\",\"梁琦\",\"椰果\"]\n",
    "my_world = {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "075bdda0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'刘同': None, '李玲': None, '梁琦': None, '椰果': None}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my_world.fromkeys(name_list,)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6c84406f",
   "metadata": {},
   "source": [
    "## 4.2 setdefault()\n",
    "\n",
    "> 指定key为某个值，但如果该key已经存在，就不执行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "54c81623",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'咬人'"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tinydict = {\n",
    "    '刘同': '活泼开朗，非常有主见',\n",
    "    '李玲': '活泼开朗',\n",
    "    '梁琦': '非常有主见'\n",
    "}\n",
    "tinydict.setdefault('椰果','咬人')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "35e8230e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<function dict.setdefault(key, default=None, /)>"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tinydict.setdefault"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "6b01242c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'刘同': '活泼开朗，非常有主见', '李玲': '活泼开朗', '梁琦': '非常有主见', '椰果': '咬人'}"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tinydict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "14a18c79",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<function dict.setdefault(key, default=None, /)>"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tinydict.setdefault"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "b64f3780",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'刘同': '活泼开朗，非常有主见', '李玲': '活泼开朗', '梁琦': '非常有主见', '椰果': '咬人'}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tinydict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "65d90ff0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'活泼开朗，非常有主见'"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tinydict['刘同']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "93fceb38",
   "metadata": {},
   "source": [
    "# 5.实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9de66366",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid decimal literal (3731728798.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[1], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m    geo_nfu = {5acd7cb488320a79e9ef7a1c3c1f8bc0}\u001b[0m\n\u001b[1;37m               ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid decimal literal\n"
     ]
    }
   ],
   "source": [
    "geo_nfu = {5acd7cb488320a79e9ef7a1c3c1f8bc0}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f97eef1a",
   "metadata": {},
   "outputs": [],
   "source": [
    "geo_nfu = {\n",
    "    \"status\": \"1\",\n",
    "    \"regeocode\": {\n",
    "        \"roads\": [\n",
    "            {\n",
    "                \"id\": \"020F49F0050461206\",\n",
    "                \"location\": \"113.678,23.6285\",\n",
    "                \"direction\": \"西南\",\n",
    "                \"name\": \"博学路\",\n",
    "                \"distance\": \"6.90071\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"020F49F0050462229\",\n",
    "                \"location\": \"113.679,23.6245\",\n",
    "                \"direction\": \"北\",\n",
    "                \"name\": \"老虎形街\",\n",
    "                \"distance\": \"444.65\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"020F49F005046601453\",\n",
    "                \"location\": \"113.677,23.6347\",\n",
    "                \"direction\": \"南\",\n",
    "                \"name\": \"中山路\",\n",
    "                \"distance\": \"711.935\"\n",
    "            }\n",
    "        ],\n",
    "        \"roadinters\": [\n",
    "            {\n",
    "                \"second_name\": \"中山路\",\n",
    "                \"first_id\": \"020F49F0050461206\",\n",
    "                \"second_id\": \"020F49F005046601453\",\n",
    "                \"location\": \"113.676745,23.634493\",\n",
    "                \"distance\": \"689.536\",\n",
    "                \"first_name\": \"博学路\",\n",
    "                \"direction\": \"南\"\n",
    "            }\n",
    "        ],\n",
    "        \"formatted_address\": \"广东省广州市从化区温泉镇博学路广州南方学院\",\n",
    "        \"addressComponent\": {\n",
    "            \"city\": \"广州市\",\n",
    "            \"province\": \"广东省\",\n",
    "            \"adcode\": \"440117\",\n",
    "            \"district\": \"从化区\",\n",
    "            \"towncode\": \"440117100000\",\n",
    "            \"streetNumber\": {\n",
    "                \"number\": \"24号\",\n",
    "                \"location\": \"113.677267,23.629149\",\n",
    "                \"direction\": \"西北\",\n",
    "                \"distance\": \"111.858\",\n",
    "                \"street\": \"博学路\"\n",
    "            },\n",
    "            \"country\": \"中国\",\n",
    "            \"township\": \"温泉镇\",\n",
    "            \"businessAreas\": [\n",
    "                []\n",
    "            ],\n",
    "            \"building\": {\n",
    "                \"name\": [],\n",
    "                \"type\": []\n",
    "            },\n",
    "            \"neighborhood\": {\n",
    "                \"name\": [],\n",
    "                \"type\": []\n",
    "            },\n",
    "            \"citycode\": \"020\"\n",
    "        },\n",
    "        \"aois\": [\n",
    "            {\n",
    "                \"area\": \"530435.909488\",\n",
    "                \"type\": \"141201\",\n",
    "                \"id\": \"B00140MR9A\",\n",
    "                \"location\": \"113.679240,23.632576\",\n",
    "                \"adcode\": \"440117\",\n",
    "                \"name\": \"广州南方学院\",\n",
    "                \"distance\": \"0\"\n",
    "            }\n",
    "        ],\n",
    "        \"pois\": [\n",
    "            {\n",
    "                \"id\": \"B00140MR9A\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号\",\n",
    "                \"poiweight\": \"0.450402\",\n",
    "                \"name\": \"广州南方学院\",\n",
    "                \"location\": \"113.679240,23.632576\",\n",
    "                \"distance\": \"481.259\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;学校;高等院校\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFK8J7XY\",\n",
    "                \"direction\": \"东\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院\",\n",
    "                \"poiweight\": \"0.233244\",\n",
    "                \"name\": \"广州南方学院(东南门)\",\n",
    "                \"location\": \"113.678689,23.628304\",\n",
    "                \"distance\": \"70.9914\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"通行设施;临街院门;临街院门\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFHRJDM9\",\n",
    "                \"direction\": \"东\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"中大南方学院南门1号\",\n",
    "                \"poiweight\": \"0.256152\",\n",
    "                \"name\": \"中南公寓\",\n",
    "                \"location\": \"113.680340,23.627566\",\n",
    "                \"distance\": \"255.793\",\n",
    "                \"tel\": \"13711245345\",\n",
    "                \"type\": \"商务住宅;住宅区;住宅小区\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0H0M9NO43\",\n",
    "                \"direction\": \"东北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"博学路广州南方学院\",\n",
    "                \"poiweight\": \"0.292147\",\n",
    "                \"name\": \"广州南方学院南方湖观景台\",\n",
    "                \"location\": \"113.679464,23.630429\",\n",
    "                \"distance\": \"270.449\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"风景名胜;风景名胜;观景点\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFKP838K\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"博学路25号\",\n",
    "                \"poiweight\": \"0.191742\",\n",
    "                \"name\": \"教学楼3号(外国语学院)\",\n",
    "                \"location\": \"113.677247,23.630947\",\n",
    "                \"distance\": \"293.427\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;学校;高等院校\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFG4TAF2\",\n",
    "                \"direction\": \"东南\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉镇乌土村松浪队5号(近博学路)\",\n",
    "                \"poiweight\": \"0.237309\",\n",
    "                \"name\": \"广州南方公寓\",\n",
    "                \"location\": \"113.678983,23.627778\",\n",
    "                \"distance\": \"121.711\",\n",
    "                \"tel\": \"13622768437\",\n",
    "                \"type\": \"住宿服务;旅馆招待所;旅馆招待所\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFHC4XU0\",\n",
    "                \"direction\": \"东北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道886号\",\n",
    "                \"poiweight\": \"0.191595\",\n",
    "                \"name\": \"广州南方学院学术交流中心\",\n",
    "                \"location\": \"113.680066,23.630242\",\n",
    "                \"distance\": \"293.698\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;会展中心;会展中心\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFKP7GY5\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号\",\n",
    "                \"poiweight\": \"0.218221\",\n",
    "                \"name\": \"广州南方学院3号实验楼\",\n",
    "                \"location\": \"113.678650,23.630612\",\n",
    "                \"distance\": \"254.726\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"地名地址信息;门牌信息;楼栋号\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0GKYRKNUA\",\n",
    "                \"direction\": \"东\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉镇平岗村乌土平岗街25号(中南公寓旁)\",\n",
    "                \"poiweight\": \"0.209893\",\n",
    "                \"name\": \"乐妍茶(中大店)\",\n",
    "                \"location\": \"113.680097,23.627643\",\n",
    "                \"distance\": \"229.616\",\n",
    "                \"tel\": \"18028862548\",\n",
    "                \"type\": \"餐饮服务;冷饮店;冷饮店\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0H33OZ7BU\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"博学路广州南方学院\",\n",
    "                \"poiweight\": \"0.191148\",\n",
    "                \"name\": \"广州南方学院学术报告厅\",\n",
    "                \"location\": \"113.678698,23.631219\",\n",
    "                \"distance\": \"321.426\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;科教文化场所;科教文化场所\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0HGD588HJ\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号\",\n",
    "                \"poiweight\": \"0.221662\",\n",
    "                \"name\": \"广州南方学院4号教学楼\",\n",
    "                \"location\": \"113.677461,23.630578\",\n",
    "                \"distance\": \"248.344\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"地名地址信息;门牌信息;楼栋号\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0H1XKYTYG\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院\",\n",
    "                \"poiweight\": \"0.198742\",\n",
    "                \"name\": \"广州南方学院西区篮球场\",\n",
    "                \"location\": \"113.677741,23.629552\",\n",
    "                \"distance\": \"130.783\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"体育休闲服务;运动场馆;篮球场馆\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0JRKNVEFY\",\n",
    "                \"direction\": \"东北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉镇笃行路20、22、24号广州南方学院商业中心1层1F-001-1号\",\n",
    "                \"poiweight\": \"0.209894\",\n",
    "                \"name\": \"喜茶(广州南方学院店)\",\n",
    "                \"location\": \"113.679905,23.630533\",\n",
    "                \"distance\": \"306.475\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"餐饮服务;冷饮店;冷饮店\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0HGDU76L2\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号\",\n",
    "                \"poiweight\": \"0.221662\",\n",
    "                \"name\": \"广州南方学院2号实验楼\",\n",
    "                \"location\": \"113.678327,23.630969\",\n",
    "                \"distance\": \"287.596\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"地名地址信息;门牌信息;楼栋号\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0I1276BCM\",\n",
    "                \"direction\": \"东南\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": [],\n",
    "                \"poiweight\": \"0.257239\",\n",
    "                \"name\": \"内部地面停车场\",\n",
    "                \"location\": \"113.679445,23.627444\",\n",
    "                \"distance\": \"181.592\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"交通设施服务;停车场;专用停车场\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0I12780ZU\",\n",
    "                \"direction\": \"东南\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"内部地面停车场\",\n",
    "                \"poiweight\": \"0.203102\",\n",
    "                \"name\": \"内部地面停车场(出入口)\",\n",
    "                \"location\": \"113.679445,23.627444\",\n",
    "                \"distance\": \"181.592\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"交通设施服务;停车场;停车场出入口\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"BV11417822\",\n",
    "                \"direction\": \"东南\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"从15路从20路\",\n",
    "                \"poiweight\": \"0.400088\",\n",
    "                \"name\": \"南方学院后门总站(公交站)\",\n",
    "                \"location\": \"113.679280,23.627201\",\n",
    "                \"distance\": \"186.49\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"交通设施服务;公交车站;公交车站相关\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0IB2GMPW4\",\n",
    "                \"direction\": \"东北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉镇笃行路20、22、24号中山大学南方学院商业中心一楼1F-005\",\n",
    "                \"poiweight\": \"0.218331\",\n",
    "                \"name\": \"古茗(南方学院店)\",\n",
    "                \"location\": \"113.680105,23.630681\",\n",
    "                \"distance\": \"332.163\",\n",
    "                \"tel\": \"13717659301;18027267535\",\n",
    "                \"type\": \"餐饮服务;休闲餐饮场所;休闲餐饮场所\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0H25SMRKP\",\n",
    "                \"direction\": \"东北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院\",\n",
    "                \"poiweight\": \"0.263595\",\n",
    "                \"name\": \"广州南方学院大礼堂\",\n",
    "                \"location\": \"113.680076,23.631502\",\n",
    "                \"distance\": \"404.618\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;科教文化场所;科教文化场所\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFKMSV6B\",\n",
    "                \"direction\": \"西北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号\",\n",
    "                \"poiweight\": \"0.232574\",\n",
    "                \"name\": \"广州南方学院西学楼2号楼\",\n",
    "                \"location\": \"113.675891,23.630025\",\n",
    "                \"distance\": \"280.734\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"地名地址信息;门牌信息;楼栋号\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFK0MZII\",\n",
    "                \"direction\": \"东\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院后门润泰超市一楼\",\n",
    "                \"poiweight\": \"0.10175\",\n",
    "                \"name\": \"街电(尚千谷中大南方店)\",\n",
    "                \"location\": \"113.680254,23.627804\",\n",
    "                \"distance\": \"238.998\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"生活服务;共享设备;充电宝\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFKP81F0\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"博学路与中山路交叉口南340米\",\n",
    "                \"poiweight\": \"0.191742\",\n",
    "                \"name\": \"教学楼1号(文学与传媒学院)\",\n",
    "                \"location\": \"113.676866,23.631736\",\n",
    "                \"distance\": \"388.545\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;科教文化场所;科教文化场所\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0HRV1D5FP\",\n",
    "                \"direction\": \"东北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院\",\n",
    "                \"poiweight\": \"0.191158\",\n",
    "                \"name\": \"广州南方学院博物馆\",\n",
    "                \"location\": \"113.679624,23.631631\",\n",
    "                \"distance\": \"395.557\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;博物馆;博物馆\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0HGDU99RM\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院内\",\n",
    "                \"poiweight\": \"0.257947\",\n",
    "                \"name\": \"广州南方学院图书馆\",\n",
    "                \"location\": \"113.679303,23.632322\",\n",
    "                \"distance\": \"455.877\",\n",
    "                \"tel\": \"020-61787368;020-61787371\",\n",
    "                \"type\": \"科教文化服务;图书馆;图书馆\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0H1YMW8PH\",\n",
    "                \"direction\": \"西北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉镇中山大学南方学院博学路6号西区食堂首层\",\n",
    "                \"poiweight\": \"0.214311\",\n",
    "                \"name\": \"肯德基(从化南方学院店)\",\n",
    "                \"location\": \"113.676031,23.631594\",\n",
    "                \"distance\": \"407.888\",\n",
    "                \"tel\": \"4009200715\",\n",
    "                \"type\": \"餐饮服务;快餐厅;快餐厅\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0FFH6K3U9\",\n",
    "                \"direction\": \"西北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉镇温泉大道882号广州南方学院H7栋1-5层\",\n",
    "                \"poiweight\": \"0.254885\",\n",
    "                \"name\": \"广州中大南方招待所\",\n",
    "                \"location\": \"113.676330,23.631332\",\n",
    "                \"distance\": \"367.753\",\n",
    "                \"tel\": \"020-61787222\",\n",
    "                \"type\": \"住宿服务;住宿服务相关;住宿服务相关\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0HGDU92JD\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号\",\n",
    "                \"poiweight\": \"0.221662\",\n",
    "                \"name\": \"广州南方学院1号教学楼\",\n",
    "                \"location\": \"113.676968,23.631720\",\n",
    "                \"distance\": \"383.861\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"地名地址信息;门牌信息;楼栋号\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0JBGSFI8C\",\n",
    "                \"direction\": \"西北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号\",\n",
    "                \"poiweight\": \"0.115716\",\n",
    "                \"name\": \"广州南方学院西学楼1号楼\",\n",
    "                \"location\": \"113.675570,23.630596\",\n",
    "                \"distance\": \"347.74\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"地名地址信息;门牌信息;楼栋号\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0JBGSCQ5R\",\n",
    "                \"direction\": \"西北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院\",\n",
    "                \"poiweight\": \"0.276093\",\n",
    "                \"name\": \"广州南方学院招待所\",\n",
    "                \"location\": \"113.675341,23.630898\",\n",
    "                \"distance\": \"387.993\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"住宿服务;旅馆招待所;旅馆招待所\"\n",
    "            },\n",
    "            {\n",
    "                \"id\": \"B0HGD58NF8\",\n",
    "                \"direction\": \"北\",\n",
    "                \"businessarea\": [],\n",
    "                \"address\": \"温泉大道882号广州南方学院新综合楼2层\",\n",
    "                \"poiweight\": \"0.191229\",\n",
    "                \"name\": \"广州南方学院达人书院\",\n",
    "                \"location\": \"113.679041,23.632392\",\n",
    "                \"distance\": \"456.4\",\n",
    "                \"tel\": [],\n",
    "                \"type\": \"科教文化服务;学校;高等院校\"\n",
    "            }\n",
    "        ]\n",
    "    },\n",
    "    \"info\": \"OK\",\n",
    "    \"infocode\": \"10000\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "92195809",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'regeocode': {'roads': [{'id': '020F49F0050461206',\n",
       "    'location': '113.678,23.6285',\n",
       "    'direction': '西南',\n",
       "    'name': '博学路',\n",
       "    'distance': '6.90071'},\n",
       "   {'id': '020F49F0050462229',\n",
       "    'location': '113.679,23.6245',\n",
       "    'direction': '北',\n",
       "    'name': '老虎形街',\n",
       "    'distance': '444.65'},\n",
       "   {'id': '020F49F005046601453',\n",
       "    'location': '113.677,23.6347',\n",
       "    'direction': '南',\n",
       "    'name': '中山路',\n",
       "    'distance': '711.935'}],\n",
       "  'roadinters': [{'second_name': '中山路',\n",
       "    'first_id': '020F49F0050461206',\n",
       "    'second_id': '020F49F005046601453',\n",
       "    'location': '113.676745,23.634493',\n",
       "    'distance': '689.536',\n",
       "    'first_name': '博学路',\n",
       "    'direction': '南'}],\n",
       "  'formatted_address': '广东省广州市从化区温泉镇博学路广州南方学院',\n",
       "  'addressComponent': {'city': '广州市',\n",
       "   'province': '广东省',\n",
       "   'adcode': '440117',\n",
       "   'district': '从化区',\n",
       "   'towncode': '440117100000',\n",
       "   'streetNumber': {'number': '24号',\n",
       "    'location': '113.677267,23.629149',\n",
       "    'direction': '西北',\n",
       "    'distance': '111.858',\n",
       "    'street': '博学路'},\n",
       "   'country': '中国',\n",
       "   'township': '温泉镇',\n",
       "   'businessAreas': [[]],\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'citycode': '020'},\n",
       "  'aois': [{'area': '530435.909488',\n",
       "    'type': '141201',\n",
       "    'id': 'B00140MR9A',\n",
       "    'location': '113.679240,23.632576',\n",
       "    'adcode': '440117',\n",
       "    'name': '广州南方学院',\n",
       "    'distance': '0'}],\n",
       "  'pois': [{'id': 'B00140MR9A',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.450402',\n",
       "    'name': '广州南方学院',\n",
       "    'location': '113.679240,23.632576',\n",
       "    'distance': '481.259',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;高等院校'},\n",
       "   {'id': 'B0FFK8J7XY',\n",
       "    'direction': '东',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.233244',\n",
       "    'name': '广州南方学院(东南门)',\n",
       "    'location': '113.678689,23.628304',\n",
       "    'distance': '70.9914',\n",
       "    'tel': [],\n",
       "    'type': '通行设施;临街院门;临街院门'},\n",
       "   {'id': 'B0FFHRJDM9',\n",
       "    'direction': '东',\n",
       "    'businessarea': [],\n",
       "    'address': '中大南方学院南门1号',\n",
       "    'poiweight': '0.256152',\n",
       "    'name': '中南公寓',\n",
       "    'location': '113.680340,23.627566',\n",
       "    'distance': '255.793',\n",
       "    'tel': '13711245345',\n",
       "    'type': '商务住宅;住宅区;住宅小区'},\n",
       "   {'id': 'B0H0M9NO43',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路广州南方学院',\n",
       "    'poiweight': '0.292147',\n",
       "    'name': '广州南方学院南方湖观景台',\n",
       "    'location': '113.679464,23.630429',\n",
       "    'distance': '270.449',\n",
       "    'tel': [],\n",
       "    'type': '风景名胜;风景名胜;观景点'},\n",
       "   {'id': 'B0FFKP838K',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路25号',\n",
       "    'poiweight': '0.191742',\n",
       "    'name': '教学楼3号(外国语学院)',\n",
       "    'location': '113.677247,23.630947',\n",
       "    'distance': '293.427',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;高等院校'},\n",
       "   {'id': 'B0FFG4TAF2',\n",
       "    'direction': '东南',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
       "    'poiweight': '0.237309',\n",
       "    'name': '广州南方公寓',\n",
       "    'location': '113.678983,23.627778',\n",
       "    'distance': '121.711',\n",
       "    'tel': '13622768437',\n",
       "    'type': '住宿服务;旅馆招待所;旅馆招待所'},\n",
       "   {'id': 'B0FFHC4XU0',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道886号',\n",
       "    'poiweight': '0.191595',\n",
       "    'name': '广州南方学院学术交流中心',\n",
       "    'location': '113.680066,23.630242',\n",
       "    'distance': '293.698',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;会展中心;会展中心'},\n",
       "   {'id': 'B0FFKP7GY5',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.218221',\n",
       "    'name': '广州南方学院3号实验楼',\n",
       "    'location': '113.678650,23.630612',\n",
       "    'distance': '254.726',\n",
       "    'tel': [],\n",
       "    'type': '地名地址信息;门牌信息;楼栋号'},\n",
       "   {'id': 'B0GKYRKNUA',\n",
       "    'direction': '东',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇平岗村乌土平岗街25号(中南公寓旁)',\n",
       "    'poiweight': '0.209893',\n",
       "    'name': '乐妍茶(中大店)',\n",
       "    'location': '113.680097,23.627643',\n",
       "    'distance': '229.616',\n",
       "    'tel': '18028862548',\n",
       "    'type': '餐饮服务;冷饮店;冷饮店'},\n",
       "   {'id': 'B0H33OZ7BU',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路广州南方学院',\n",
       "    'poiweight': '0.191148',\n",
       "    'name': '广州南方学院学术报告厅',\n",
       "    'location': '113.678698,23.631219',\n",
       "    'distance': '321.426',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       "   {'id': 'B0HGD588HJ',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院4号教学楼',\n",
       "    'location': '113.677461,23.630578',\n",
       "    'distance': '248.344',\n",
       "    'tel': [],\n",
       "    'type': '地名地址信息;门牌信息;楼栋号'},\n",
       "   {'id': 'B0H1XKYTYG',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.198742',\n",
       "    'name': '广州南方学院西区篮球场',\n",
       "    'location': '113.677741,23.629552',\n",
       "    'distance': '130.783',\n",
       "    'tel': [],\n",
       "    'type': '体育休闲服务;运动场馆;篮球场馆'},\n",
       "   {'id': 'B0JRKNVEFY',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇笃行路20、22、24号广州南方学院商业中心1层1F-001-1号',\n",
       "    'poiweight': '0.209894',\n",
       "    'name': '喜茶(广州南方学院店)',\n",
       "    'location': '113.679905,23.630533',\n",
       "    'distance': '306.475',\n",
       "    'tel': [],\n",
       "    'type': '餐饮服务;冷饮店;冷饮店'},\n",
       "   {'id': 'B0HGDU76L2',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院2号实验楼',\n",
       "    'location': '113.678327,23.630969',\n",
       "    'distance': '287.596',\n",
       "    'tel': [],\n",
       "    'type': '地名地址信息;门牌信息;楼栋号'},\n",
       "   {'id': 'B0I1276BCM',\n",
       "    'direction': '东南',\n",
       "    'businessarea': [],\n",
       "    'address': [],\n",
       "    'poiweight': '0.257239',\n",
       "    'name': '内部地面停车场',\n",
       "    'location': '113.679445,23.627444',\n",
       "    'distance': '181.592',\n",
       "    'tel': [],\n",
       "    'type': '交通设施服务;停车场;专用停车场'},\n",
       "   {'id': 'B0I12780ZU',\n",
       "    'direction': '东南',\n",
       "    'businessarea': [],\n",
       "    'address': '内部地面停车场',\n",
       "    'poiweight': '0.203102',\n",
       "    'name': '内部地面停车场(出入口)',\n",
       "    'location': '113.679445,23.627444',\n",
       "    'distance': '181.592',\n",
       "    'tel': [],\n",
       "    'type': '交通设施服务;停车场;停车场出入口'},\n",
       "   {'id': 'BV11417822',\n",
       "    'direction': '东南',\n",
       "    'businessarea': [],\n",
       "    'address': '从15路从20路',\n",
       "    'poiweight': '0.400088',\n",
       "    'name': '南方学院后门总站(公交站)',\n",
       "    'location': '113.679280,23.627201',\n",
       "    'distance': '186.49',\n",
       "    'tel': [],\n",
       "    'type': '交通设施服务;公交车站;公交车站相关'},\n",
       "   {'id': 'B0IB2GMPW4',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇笃行路20、22、24号中山大学南方学院商业中心一楼1F-005',\n",
       "    'poiweight': '0.218331',\n",
       "    'name': '古茗(南方学院店)',\n",
       "    'location': '113.680105,23.630681',\n",
       "    'distance': '332.163',\n",
       "    'tel': '13717659301;18027267535',\n",
       "    'type': '餐饮服务;休闲餐饮场所;休闲餐饮场所'},\n",
       "   {'id': 'B0H25SMRKP',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.263595',\n",
       "    'name': '广州南方学院大礼堂',\n",
       "    'location': '113.680076,23.631502',\n",
       "    'distance': '404.618',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       "   {'id': 'B0FFKMSV6B',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.232574',\n",
       "    'name': '广州南方学院西学楼2号楼',\n",
       "    'location': '113.675891,23.630025',\n",
       "    'distance': '280.734',\n",
       "    'tel': [],\n",
       "    'type': '地名地址信息;门牌信息;楼栋号'},\n",
       "   {'id': 'B0FFK0MZII',\n",
       "    'direction': '东',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院后门润泰超市一楼',\n",
       "    'poiweight': '0.10175',\n",
       "    'name': '街电(尚千谷中大南方店)',\n",
       "    'location': '113.680254,23.627804',\n",
       "    'distance': '238.998',\n",
       "    'tel': [],\n",
       "    'type': '生活服务;共享设备;充电宝'},\n",
       "   {'id': 'B0FFKP81F0',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '博学路与中山路交叉口南340米',\n",
       "    'poiweight': '0.191742',\n",
       "    'name': '教学楼1号(文学与传媒学院)',\n",
       "    'location': '113.676866,23.631736',\n",
       "    'distance': '388.545',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       "   {'id': 'B0HRV1D5FP',\n",
       "    'direction': '东北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.191158',\n",
       "    'name': '广州南方学院博物馆',\n",
       "    'location': '113.679624,23.631631',\n",
       "    'distance': '395.557',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;博物馆;博物馆'},\n",
       "   {'id': 'B0HGDU99RM',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院内',\n",
       "    'poiweight': '0.257947',\n",
       "    'name': '广州南方学院图书馆',\n",
       "    'location': '113.679303,23.632322',\n",
       "    'distance': '455.877',\n",
       "    'tel': '020-61787368;020-61787371',\n",
       "    'type': '科教文化服务;图书馆;图书馆'},\n",
       "   {'id': 'B0H1YMW8PH',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇中山大学南方学院博学路6号西区食堂首层',\n",
       "    'poiweight': '0.214311',\n",
       "    'name': '肯德基(从化南方学院店)',\n",
       "    'location': '113.676031,23.631594',\n",
       "    'distance': '407.888',\n",
       "    'tel': '4009200715',\n",
       "    'type': '餐饮服务;快餐厅;快餐厅'},\n",
       "   {'id': 'B0FFH6K3U9',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
       "    'poiweight': '0.254885',\n",
       "    'name': '广州中大南方招待所',\n",
       "    'location': '113.676330,23.631332',\n",
       "    'distance': '367.753',\n",
       "    'tel': '020-61787222',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       "   {'id': 'B0HGDU92JD',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.221662',\n",
       "    'name': '广州南方学院1号教学楼',\n",
       "    'location': '113.676968,23.631720',\n",
       "    'distance': '383.861',\n",
       "    'tel': [],\n",
       "    'type': '地名地址信息;门牌信息;楼栋号'},\n",
       "   {'id': 'B0JBGSFI8C',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.115716',\n",
       "    'name': '广州南方学院西学楼1号楼',\n",
       "    'location': '113.675570,23.630596',\n",
       "    'distance': '347.74',\n",
       "    'tel': [],\n",
       "    'type': '地名地址信息;门牌信息;楼栋号'},\n",
       "   {'id': 'B0JBGSCQ5R',\n",
       "    'direction': '西北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.276093',\n",
       "    'name': '广州南方学院招待所',\n",
       "    'location': '113.675341,23.630898',\n",
       "    'distance': '387.993',\n",
       "    'tel': [],\n",
       "    'type': '住宿服务;旅馆招待所;旅馆招待所'},\n",
       "   {'id': 'B0HGD58NF8',\n",
       "    'direction': '北',\n",
       "    'businessarea': [],\n",
       "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
       "    'poiweight': '0.191229',\n",
       "    'name': '广州南方学院达人书院',\n",
       "    'location': '113.679041,23.632392',\n",
       "    'distance': '456.4',\n",
       "    'tel': [],\n",
       "    'type': '科教文化服务;学校;高等院校'}]},\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000'}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geo_nfu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3eb64180",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'dict'>\n"
     ]
    }
   ],
   "source": [
    "print(type(geo_nfu))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee32f6d4",
   "metadata": {},
   "source": [
    "# 实践答案：\n",
    "\n",
    "> 1. keys有哪些？\n",
    "> 2. roads 有哪些？\n",
    "> 3. name 有哪些？\n",
    "> 4. direction 为 北的 name 有哪些？\n",
    "> 5. 有 tel 的 建筑（name）有哪些？\n",
    "> 6. type 为\"餐饮服务\"有哪些？\n",
    "> 7. distance 小于200米的建筑设施有哪些？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "7ec486c2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'regeocode', 'status', 'infocode', 'info'}\n"
     ]
    }
   ],
   "source": [
    "data = set(geo_nfu)\n",
    "print(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "8e021cd7",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "roads有： [{'id': '020F49F0050461206', 'location': '113.678,23.6285', 'direction': '西南', 'name': '博学路', 'distance': '6.90071'}, {'id': '020F49F0050462229', 'location': '113.679,23.6245', 'direction': '北', 'name': '老虎形街', 'distance': '444.65'}, {'id': '020F49F005046601453', 'location': '113.677,23.6347', 'direction': '南', 'name': '中山路', 'distance': '711.935'}]\n"
     ]
    }
   ],
   "source": [
    "roads = geo_nfu.get('regeocode', {}).get('roads')\n",
    "print(\"roads有：\",roads)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "b2af45f0",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'id'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[98], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m names \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28mid\u001b[39m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m \u001b[38;5;28mid\u001b[39m \u001b[38;5;129;01min\u001b[39;00m geo_nfu [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mregeocode\u001b[39m\u001b[38;5;124m'\u001b[39m][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mid\u001b[39m\u001b[38;5;124m'\u001b[39m]]\n\u001b[0;32m      2\u001b[0m \u001b[38;5;28mprint\u001b[39m(names)\n",
      "\u001b[1;31mKeyError\u001b[0m: 'id'"
     ]
    }
   ],
   "source": [
    "names = [['name'] for  in geo_nfu ['regeocode']\n",
    "print(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "80fa3d2a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "1654e711",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['regeocode'] [0] ['name']\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "1f504ab0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "71fb6e3c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
